package com.wbdca.crawler.common;

import org.apache.hc.client5.http.classic.methods.HttpGet;

import java.util.ArrayList;

public class FineGrainedTokens {
    private static final ArrayList<String> tokens = new ArrayList<String>(){
        {
            // Created on Sat, Nov 12 2022 by Fermansky. Expires on Sun, Dec 18 2022.
            add("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");
        }
    };
    private static int tokenPointer = 0;

    public static String getToken(){
        return tokens.get(tokenPointer);
    }

    public static void updatePointer(){
        tokenPointer += 1;
        if(tokenPointer >= tokens.size()){
            tokenPointer = 0;
        }
    }

    public static void addAuthorization(HttpGet httpGet){
        httpGet.addHeader("Authorization", "Bearer "+getToken());
    }
}
